<template>
  <el-row class="sel-plat">
    <el-col :span="24"
            class="ul-box">
      <ul>
        <li v-for="(item,i) in selArr"
            :key="i"
            @click="onJump(item)">{{item.name}}</li>
      </ul>
    </el-col>
    <el-col :span="24"
            class="bottom-box">
      <p>默认登录平台</p>
      <el-select v-model="defaultVal"
                 :disabled="true"
                 placeholder="请选择">
        <el-option v-for="item in selArr"
                   :key="item.url"
                   :label="item.name"
                   :value="item.url">
        </el-option>
      </el-select>
    </el-col>
  </el-row>
</template>

<script>
import { MyCompanyApi } from '@/services/WorkBench';
export default {
  props: {
    judgeOpen: Number,
    entryPlatObj: Object
  },
  data () {
    return {
      defaultVal: '',
      selArr: [{ name: '智慧工地公共平台', url: '0' }, { name: '工业化建筑管理平台', url: process.env.HZJW_URL }, { name: '实测实量', url: process.env.SCSL_URL }, { name: '分户验收', url: process.env.FHYS_URL }]
    }
  },
  methods: {
    //跳转到平台
    onJump (row) {
      var str = window.location.href;//当前url
      console.log(str.indexOf("/workbenchMyUnit") != -1);  // true
      if (row.url == '0' && str.indexOf("/workbenchMyUnit") == -1) {
        this.$message.warning('当前"' + this.selArr[0].name + '"已是默认的平台');
      } else if (row.url == '0' && str.indexOf("/workbenchMyUnit") != -1) {
        this.$router.push({ path: '/homepage' })
      } else {
        window.open(row.url, '_blank')
      }
    }
  },
  watch: {
    judgeOpen (n, o) {
      console.log('w-judgeOpen=', this.judgeOpen, 'entryPlatObj=', this.entryPlatObj)
    },
  },
  created () {
    this.selArr[0].name = JSON.parse(localStorage.companyInfo).company_name
    this.defaultVal = this.selArr[0].url;
    console.log('c-judgeOpen=', this.judgeOpen, 'entryPlatObj=', this.entryPlatObj)
  }
}
</script>

<style lang="scss" scoped>
.ul-box ul {
  width: 100%;
}
.ul-box ul li {
  width: -webkit-calc(25% - 20px);
  // border: 1px solid #666666;
  height: 40px;
  line-height: 40px;
  float: left;
  margin-bottom: 20px;
  text-align: center;
  border-radius: 4px;
  // box-shadow: 4px 4px 4px 4px #d0d0d0;
  margin-left: 20px;
  cursor: pointer;
  background-color: #409eff;
  color: white;
}
.bottom-box {
  padding-left: 20px;
  padding-top: 20px;
  padding-bottom: 20px;
  p {
    margin-bottom: 20px;
    font-size: 14px;
  }
}
</style>